<table id="admin_equ_info" data-options="fit:true"></table>
<div id="equInfo_toolbar"
	style="padding: 0 10px; height: 35px; line-height: 35px;">
	<input class="icon-add" type="button" value="添加新设备" onclick="openEquWin()"
		style="padding:3px 3px 3px 20px; border: 1px #999 solid; margin: 2px; border-radius: 5px;" />
	<input class="icon-reload" type="button" value="刷新" onclick="flushEqu()"
		style="padding:3px 3px 3px 20px; border: 1px #999 solid; margin: 2px; border-radius: 5px;" />
</div>
<script>
$(function(){
	$('#admin_equ_info').datagrid({
		url:'../shebeiInfo/SheBeiInfo_getSheBeiList',
		loadMsg:'数据加载中...',
		fitColumns:true,
		rownumbers:true,
		striped:true,
		sortName:'sid',
		sortOrder:'asc',
		remoteSort:false,
		columns:[[
			{field:'sid',title:'设备编号',width:100,align:'center',sortable:true},
			{field:'sname',title:'设备名称',width:100,align:'center'}, 
			{field:'stype',title:'设备类型',width:100,align:'center'},
			{field:'sprice',title:'设备价格',width:100,align:'center'}
		]],
		toolbar:"#equInfo_toolbar"
	});
});

function flushEqu(){
	$('#admin_equ_info').datagrid("reload");
}

//添加新设备
function addEquInfo(){
	var sname = $.trim($("#equ_sname").val());          
	var stype = $.trim($("#equ_stype").val());
	var sprice = $.trim($("#equ_sprice").val());
	
	//为空判断
	if(sname!="" && stype!="" && sprice!="") {
		$.post("../shebeiInfo/SheBeiInfo_addSheBeiInfo",{"sbi.sname":sname,"sbi.stype":stype,"sbi.sprice":sprice},function(data){
			if(parseInt(data.result) > 0) {
				$.messager.show({
					title:'成功提示',
					msg:'添加成功!',
					timeout:3000,
					showType:'slide'
				});
				$("#equ_sname").val("");
				$("#equ_stype").val("");
				$("#equ_sprice").val("");
				$("#add_equ_info").dialog("close");
				$('#admin_equ_info').datagrid("reload");
			} else {
				$.messager.alert('错误提示','设备信息添加失败!','error');
			}
		});
	} else {
		$.messager.show({
			title:'温馨提示',
			msg:'您输入的信息不完整，请确认后再提交!',
			timeout:3000,
			showType:'slide'
		});
	}
}


//打开添加窗口
function openEquWin() {
	$("#add_equ_info").dialog("open");
}
</script>
<div id="add_equ_info" class="easyui-dialog" title="充值" style="width: 400px; height: 260px;"
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">
	<p style="width: 100%; text-align: center;">
		<br /><br />
		<label for="equ_sname">设备名称：</label><input type="text" id="equ_sname"/>
		<br /><br />
		<label for="equ_stype">设备类型：</label><input type="text" id="equ_stype"/> 
		<br /><br />
		<label for="equ_sprice">设备价格：</label><input type="text" id="equ_sprice"/>
		<br /><br />
		<input style="padding: 5px 25px;" type="button" onclick="addEquInfo()" value="添加"/>
	</p>
</div>
